<template>
	<view class="container">
		<course :courseList="list"></course>
		<emptyData :width="empty.width" :height="empty.height" :text="empty.text" :icon="empty.icon" :marginTop="empty.marginTop" v-if="list.length == 0"></emptyData>
	</view>
</template>

<script>
	import course from '../../components/course/course.vue'
	export default {
		components: {
			course
		},
		data() {
			return {
				type: '',
				list: [],
				page: 1,
				empty: {
					width: 135,
					height: 134,
					text: '暂无数据',
					icon: '/image/emptyAddress.png',
					marginTop: 100
				},
			}
		},
		onLoad(data) {
			this.type = data.type;
			uni.setNavigationBarTitle({
				title: data.title
			})
			this.getList()
		},
		onReachBottom() {
		  this.page++
		  this.getList()
		},
		methods: {
			getList() {
			  this.$api.sendRequest({
			      url: "/api/socialize/classlist",
			      data: {
			        page: this.page,
					page_size: 20,
			        type: this.type
			      },
			      success: res => {
			        if(res.code == 0) {
						if(this.page == 1) this.list = []
						this.list = [...this.list, ...res.data.list]

						
			        } 
			      }
			    })
			},
		}
	}
</script>

<style lang="scss" scoped>

</style>
